Time\Duration - #23073
Open
TimWolla wants to merge 3 commits into
Open
Conversation
derickr
reviewed
Aug 5, 2026
arnaud-lb
reviewed
Aug 5, 2026
|
|
||
| php_date_time_duration *original = Z_DATE_TIME_DURATION_P(ZEND_THIS); | ||
| php_date_time_duration *additional = php_date_time_duration_from_obj(duration); | ||
| php_date_time_duration *new = Z_DATE_TIME_DURATION_P(return_value); |
Member
There was a problem hiding this comment.
When either original or additional has recount==1, it may be possible to reuse it?
arnaud-lb
reviewed
Aug 5, 2026
TimWolla
force-pushed
the
time-duration
branch
8 times, most recently
from
August 5, 2026 20:09
ebb8107 to
5f203d8
Compare
TimWolla
force-pushed
the
time-duration
branch
2 times, most recently
from
August 5, 2026 20:43
89e45ab to
6390166
Compare
TimWolla
commented
Aug 5, 2026
TimWolla
commented
Aug 5, 2026
TimWolla
commented
Aug 5, 2026
TimWolla
force-pushed
the
time-duration
branch
3 times, most recently
from
August 6, 2026 07:45
1f0ff1f to
9e932e2
Compare
TimWolla
force-pushed
the
time-duration
branch
2 times, most recently
from
August 6, 2026 08:23
95eee76 to
a2a58e7
Compare
nyamsprod
reviewed
Aug 6, 2026
derickr
reviewed
Aug 6, 2026
…om*()`
This is useful for patterns like the following:
for (;;) {
$watchers = $poll->wait(Time\Duration::fromSeconds(1));
// …
}
which is repeatedly creating identical duration objects for every loop
iteration.
arnaud-lb
approved these changes
Aug 6, 2026
Comment on lines
+98
to
+100
| ZVAL_LONG(OBJ_PROP_NUM(&object->std, 0), object->duration.seconds); | ||
| ZVAL_LONG(OBJ_PROP_NUM(&object->std, 1), object->duration.nanoseconds); | ||
| ZVAL_BOOL(OBJ_PROP_NUM(&object->std, 2), object->duration.negative); |
Member
There was a problem hiding this comment.
Probably harmless, but we should reset prop flags here with Z_PROP_FLAG_P(variable_ptr) &= ~(IS_PROP_UNINIT|IS_PROP_REINITABLE);
| /* This constraint is an explicit part of PHP's API. While it is currently also | ||
| * enforced by timelib, this might change in a future version of timelib, thus | ||
| * we also enforce it manually. */ | ||
| || object->duration.seconds > ((timelib_ull)UINT64_C(9223372035)) |
Member
There was a problem hiding this comment.
Can we add a comment about how this constraint was chosen? It's documented in the RFC but not in the code, I believe
Member
Author
There was a problem hiding this comment.
That makes sense and will be done with the next push.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC: https://wiki.php.net/rfc/duration_class